//
//  WJCustomXibTableViewController.m
//  JerryIos
//
//  Created by 王军 on 2018/2/2.
//  Copyright © 2018年 王军. All rights reserved.
//

#import "WJXibTableController.h"
#import "WJXibTableCell.h"
#import "WJShop.h"

@interface WJXibTableController ()

@property (nonatomic, strong) NSMutableArray *shopArray;

@end

@implementation WJXibTableController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //取消系统自带的分隔线。
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    
    self.tableView.rowHeight = 80;
}

-(NSArray *)shopArray {
    if (_shopArray == nil) {
        WJShop *shop1 = [[WJShop alloc] init];
        shop1.icon = @"icon_home";
        shop1.title = @"aaa";
        shop1.desc = @"aaa";
        shop1.price = @"45";
        
        WJShop *shop2 = [[WJShop alloc] init];
        shop2.icon = @"icon_home";
        shop2.title = @"bbb";
        shop2.desc = @"bbb";
        shop2.price = @"55";
        
        _shopArray = [NSMutableArray array];
        [_shopArray addObject:shop1];
        [_shopArray addObject:shop2];
    }
    return _shopArray;
}

#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.shopArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    WJXibTableCell *cell = [WJXibTableCell cellWithTableView:tableView];
    cell.shop = self.shopArray[indexPath.row];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

@end
